package com.project.personalfundmanager.shared.models;

import com.extjs.gxt.ui.client.data.BaseModel;
import com.project.personalfundmanager.client.common.Const;
import com.project.personalfundmanager.client.common.ModelHelper;
import com.project.personalfundmanager.client.listeners.Displayable;
import com.project.personalfundmanager.shared.DAOs.Section10DAO;

public class Section10Model extends BaseModel implements Displayable
{
	private static final long serialVersionUID = 4633628298895722361L;
	StringWrapperModel model;
	
	public Section10Model( Section10DAO dao )
	{
		setLTA( dao.getLta() );
		setRentPaid( dao.getRentPaid() );
		setMedical( dao.getMedical() );
		setTypeofCity( dao.getTypeOfCity() );
		setCalculatedHRA( dao.getCalculatedHra() );
		setTotal( dao.getTotal() );
	}
	
	public static void copyToModel( Section10Model fromModel, Section10Model toModel )
	{
		toModel.setLTA( fromModel.getLTA() );
		toModel.setRentPaid( fromModel.getRentPaid() );
		toModel.setMedical( fromModel.getMedical() );
		toModel.setTypeofCity( fromModel.getTypeofCity() );
		toModel.setCalculatedHRA( fromModel.getCalculatedHRA());
		toModel.setTotal( fromModel.getTotal() );
	}

	public Section10Model()
	{
		setDisplayString();
	}

	public void setDisplayString()
	{
		set( "displayString", "Sec 10 Exemption" );
	}

	public void setLTA( Integer lta )
	{
		set( Const.LTA, lta );
	}

	public Integer getLTA()
	{
		return ModelHelper.getNullSafeInt( get( Const.LTA ) );
	}

	public void setRentPaid( Integer rentPaid )
	{
		set( Const.RENT_PAID, rentPaid );
	}

	public Integer getRentPaid()
	{
		return ModelHelper.getNullSafeInt( get( Const.RENT_PAID ) );
	}

	public void setMedical( Integer medical )
	{
		set( Const.MEDICAL, medical );
	}

	public Integer getMedical()
	{
		return ModelHelper.getNullSafeInt( get( Const.MEDICAL ) );
	}

	public void setTypeofCity( String typeOfCity )
	{
		set( Const.TYPE_OF_CITY, new StringWrapperModel(typeOfCity) );
	}

	public String getTypeofCity()
	{
		if ( get( "typeOfCity" ) == null )
			return "Non Metro";

		return ((StringWrapperModel)get( Const.TYPE_OF_CITY )).getValue();
	}

	public void setCalculatedHRA( Integer calculatedhra )
	{
		set( Const.CALCULATED_HRA, calculatedhra );
	}

	public Integer getCalculatedHRA()
	{
		return ModelHelper.getNullSafeInt( get(Const.CALCULATED_HRA) );
	}

	public void setTotal( Integer salary )
	{
		set( Const.SEC10_TOTAL, salary );
	}

	public Integer getTotal()
	{
		return ModelHelper.getNullSafeInt( get( Const.SEC10_TOTAL ) );
	}
}
